<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="../../assets/css/base.css">
  <style>
    div {
      width: 300px;
      height: 300px;
    }

    .relative {
      position: relative;
      top: 0;
      left: 0;
      background-color: red;

      /*
        修改定位元素的层级
         ● 定位元素层级相同
         ● 通过 z-index 修改定位元素的层级
         ● z-index 取值为整数值，可以取负值。数值越大，层级越高
       */
      z-index: 1;
    }

    .absolute {
      position: absolute;
      top: 100px;
      left: 100px;
      background-color: orange;

      z-index: 0;
    }

    .fixed {
      position: fixed;
      top: 200px;
      left: 200px;
      background-color: yellow;

      z-index: -1;
    }
  </style>
</head>

<body>
  <div class="relative"></div>
  <div class="absolute"></div>
  <div class="fixed"></div>
</body>

</html>